
// 渲染子表表头操作按钮逻辑

import TableRowOperator from '../../components/TableRowOperator';

import deepCopy from '../../../../public/functions/deep-copy';
import language from '../../language';

export default function(template, areaList, busiSet) {

    let tmp = deepCopy(template);

    let btnConf = this.props.button.getButtons();
    let rowKeys = ['DelLine', 'InsLine', 'CopyLine', 'PasteLine'];
    let hasBtnFlag = btnConf.find(btn => rowKeys.includes(btn.key));
    if (!hasBtnFlag) return tmp;
    areaList.map((item) => {
        if(tmp[item].moduletype === 'table') {
            tmp[item].items.push({
                itemtype: 'customer',
                label: language['hi6007-000029'],/* 国际化处理： 操作*/
                visible: true,
                fixed: 'right',
                attrcode: 'operation',
                width: '200px',
                render: (text, record, index) => {
                    if(this.state.subTableEditable && !busiSet.includes(item)) {
                        return (
                            <TableRowOperator
                                {...this.props}
                                index={index}
                                tableId={item}
                                copyRow={this.copyRow}
                                deleteRow={this.deleteRow}
                                pasteRow={this.pasteRow}
                                addRow={this.addRow}
                                insertRow={this.insertRow}
                            />
                        );
                    }
                }
            });
        }
    });

    return tmp;
}
